package com.cgx.tablet.beeper.widget;

import android.content.Context;
import android.support.annotation.StringRes;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.cgx.tablet.beeper.R;


/**
 * CommunityResident
 * Created by Droven on 2017/12/24.
 */

public class SuccessToast extends Toast{

    public SuccessToast(Context context, @StringRes int msgRes) {
        this(context, context.getString(msgRes));
    }

    public SuccessToast(Context context, String msg) {
        super(context);
        View view = LayoutInflater.from(context).inflate(R.layout.toast_success, null);
        ((TextView) view.findViewById(R.id.success_msg)).setText(msg);
        setView(view);
        setDuration(Toast.LENGTH_SHORT);
        setGravity(Gravity.CENTER, 0, -100);
    }

    public static SuccessToast makeText(Context context, @StringRes int msgRes){
        return new SuccessToast(context, msgRes);
    }

    public static SuccessToast makeText(Context context, String msg){
        return new SuccessToast(context, msg);
    }
}
